package com.osgc.rf.unit.dao;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Category;

import com.inca.np.gui.control.DBTableModel;
import com.inca.np.util.SelectHelper;

public class TradePackInfo {
	static protected Category logger = Category.getInstance(TradePackInfo.class);
	private String packsize;
	private String packname;
	public String getPacksize() {
		return packsize;
	}
	public void setPacksize(String packsize) {
		this.packsize = packsize;
	}
	public String getPackname() {
		return packname;
	}
	public void setPackname(String packname) {
		this.packname = packname;
	}
	public String getGoodspackid() {
		return goodspackid;
	}
	public void setGoodspackid(String goodspackid) {
		this.goodspackid = goodspackid;
	}
	private String goodspackid;
	static	public TradePackInfo getPackInfos(Connection con,String ownergoodsid)throws Exception {
		
		TradePackInfo  info=null;
		String sql = "select * from tpl_goods_packs where baseunitflag=1 and ownergoodsid="+ownergoodsid;
		logger.debug(sql);
		DBTableModel db = new SelectHelper(sql).executeSelect(con, 0, 1) ;
		if(db.getRowCount()==0)return null;
		for (int i = 0; i < db.getRowCount(); i++) {
			String goodspackid = db.getItemValue(i, "goodspackid");
			String packname = db.getItemValue(i, "packname");
			String packsize = db.getItemValue(i, "packsize");
			info = new TradePackInfo(goodspackid, packname, packsize);
			
		}
		
		return info;		
	}
	public TradePackInfo() {}
	public TradePackInfo(String goodspackid,
	 String packname,
	 String packsize) {
		setGoodspackid(goodspackid);
		setPackname(packname);
		setPacksize(packsize);
	}
	
}
